
<?php

//load the client PHP library
require_once("FaceRestClient.php");
require_once("faceFunction.php");


$photo = 1;

 if( !empty($_GET['pic']) ){
	
	$photo = $_GET['pic'];
}

$dataTrainArray = getTrainingUrls();

//show datatrain in a thumbnail
foreach($dataTrainArray as $data){
	
	echo "<a href='$data'><img src='$data' height='50' width='50'></a>";
}

//initialize API object with API key and Secret, get this by registeting into developer.face.com
$apiKey = '8eb8892405ebd2d5fb70d41d7331731d';
$apiSecret = 'f5704563182d2243608f684fbe63a967';

$api = new FaceRestClient($apiKey, $apiSecret);

//the list of private-namespace UIDs to train and search for, first create namespace in Face.com API page
$uids = array("kiki@kiki.ahmadi");

//get predefined training photos URL
$sourcePhotos = getTrainingUrls($uids);

//train using train data photos, this data associated with specific names in the private-namespace
train($api,$uids[0]);

//return the image recognition result object
$result = search($api,$uids[0],$photo);

echo "<p><img src='$result->url'/></p>";
echo "<p>$result->uid ditemukan di gambar diatas (<b> $result->confidence </b> % confidence level)\n </b></p>";
                	
echo "<a href='index.php'>Pic 1</a> <a href='index.php?pic=2'>Pic 2</a>"
?>